package com.javajun.endofterm.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.javajun.endofterm.common.CommonEntity;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * Author: Xiong Limin
 * Date: 2020-11-28-6:18 下午
 */
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
public class SysUser extends CommonEntity<Integer> {

    @Column(length = 50, unique = true) // 用户名唯一索引
    private String username;

    @JsonIgnore // 密码不进行 json 序列化
    private String password; // 密码

    @Column(length = 50)
    private String name; // 真实姓名

    @Column(length = 50, unique = true) // 邮箱唯一索引
    private String email; // 邮箱

    @Column(length = 50)
    private String phone; //手机号

    @ManyToMany(cascade = CascadeType.REFRESH, fetch = FetchType.EAGER)
    @JoinColumn
    @JsonIgnore
    private List<SysRole> sysRoleList = new ArrayList<>();

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public List<SysRole> getSysRoleList() {
        return sysRoleList;
    }

    public void setSysRoleList(List<SysRole> sysRoleList) {
        this.sysRoleList = sysRoleList;
    }
}
